{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# k近邻算法实战鸢尾花分类"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>萼片长(cm)</th>\n",
       "      <th>萼片宽(cm)</th>\n",
       "      <th>花瓣长(cm)</th>\n",
       "      <th>花瓣宽(cm)</th>\n",
       "      <th>分类</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5.1</td>\n",
       "      <td>3.5</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>4.9</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>4.7</td>\n",
       "      <td>3.2</td>\n",
       "      <td>1.3</td>\n",
       "      <td>0.2</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4.6</td>\n",
       "      <td>3.1</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.2</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5.0</td>\n",
       "      <td>3.6</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   萼片长(cm)  萼片宽(cm)  花瓣长(cm)  花瓣宽(cm)  分类\n",
       "0      5.1      3.5      1.4      0.2   0\n",
       "1      4.9      3.0      1.4      0.2   0\n",
       "2      4.7      3.2      1.3      0.2   0\n",
       "3      4.6      3.1      1.5      0.2   0\n",
       "4      5.0      3.6      1.4      0.2   0"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.read_excel('iris.xlsx')\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(150, 4)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X_train = df.values[:, :4]\n",
    "X_train.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(150,)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_train = df.values[:, -1]\n",
    "y_train.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n",
       "       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n",
       "       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.,\n",
       "       1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,\n",
       "       1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,\n",
       "       1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 2., 2.,\n",
       "       2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2.,\n",
       "       2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2.,\n",
       "       2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2., 2.])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_train"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAHdJJREFUeJzt3X+MHOd93/H3l7sX22en/GEdEluU7gI4SCA5smwSihILqeqjC1lS6D/i2ipoJDJqXH3nNHYiQ7FLQJYIEFKRIlZThzQOUgo5d4nlKk6iH04bR5YbEqhVHCWbskyhUGKeeJRd05IsVWLr8u6+/WP3yLu93Ztnb56dfWb28wIWd/vM7Mx3npt9OJz5znfM3RERkWrZ0u8AREQkPg3uIiIVpMFdRKSCNLiLiFSQBncRkQrS4C4iUkEa3EVEKkiDu4hIBWlwFxGpoHrojGZWA+aA0+5+Y8u0m4E/AE43mz7v7vdstLyLLrrIx8bGugpWRGTQHTt27EfuPpI1X/DgDnwCOAH8kw7T73f33w5d2NjYGHNzc12sXkREzGw+ZL6g0zJmthO4AdjwaFxERNIQes79buBWYHmDeX7DzI6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CNLiLiFSQBncRkQrS4C4iUkH/H+Rgnc5f0ngVAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(X_train[y_train==0, 0], X_train[y_train==0, 1], color='r')\n",
    "plt.scatter(X_train[y_train==1, 0], X_train[y_train==1, 1], color='g')\n",
    "plt.scatter(X_train[y_train==2, 0], X_train[y_train==2, 1], color='b')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAGkNJREFUeJzt3X9sXWd9x/HP1/faY6YsrYgFbdrY1QZICVAgVlcEQt3cTi0ttNsQPxTGWkAeNmxUMG1AJFArRWLSYCDA6bzWaYs92NYCa2nZRgMSIH4MJyuUJEUqXdMfMGpgS+mMlsT57o9z09jX5/o+955zz6/7fklX8Xn8nPN8b1C/nDzP9zzH3F0AgGoZyDsAAED6SO4AUEEkdwCoIJI7AFQQyR0AKojkDgAVRHIHgAoiuQNABZHcAaCC6nkNvHnzZh8bG8treAAopf379//M3Ufa9cstuY+NjWlxcTGv4QGglMzsSEg/pmUAoIJI7gBQQSR3AKggkjsAVBDJHQAqiOQOABVEcgeACmqb3M3sPDP7qpkdMrODZvbumD4Xm9lRM7uv8flgb8IFUGYLC9LYmDQwEP25sJD8/KTXrKqQh5hOSHqvux8ws2dJ2m9mX3b3Q039vu7uV6YfIoAqWFiQJiel5eXo+MiR6FiSdu7s7vxrr5XMpGPHurtmlbW9c3f3n7j7gcbPv5R0WNKWXgcGoFp27Tqd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eSeOSfsPdr8w7nm6Z2cOSxt299HXhZnarpK+7+02NhyqH3f1/8o4ricbOu49L+m13T/Lszxqlu3N3968pelCq9Nz9J+5+oPHzLyUd1vpN2UrBI081Dgcbn3LdOaxiZudKukLSTXnHgoiZbZL0Kkk3S5K7Hyt7Ym+YkPSjNBO7VMLkXlVmNqboCd/v5BtJ9xrTGPdJekLSl929tN9F0RPZfyHpZN6BpMAl/ZuZ7TezybyDSeB8SUuS9jamy24ys2fmHVQK3ijpM2lflOReAGZ2hqQ7JF3n7k/mHU+33H3F3V+iaHO5C82slNNmZnalpCfcfX/esaTkle7+MkUv3HlnY2qzjOqSXiZpj7u/VNL/SnpfviEl05haeq2kf0r72iT3nDXmp++QtODun8s7njQ0/qn8VUmX5R1Ll14h6bWNuerPSvpdM5vPN6TuufvjjT+fkPR5RS/gKaPHJD226l+EtytK9mV2uaQD7v7TtC9Mcs9RYxHyZkmH3f2jeceThJmNmNmZjZ9/XdKlkh7IN6ruuPv73f1cdx9T9E/mr7j7m3MOqytm9szGYr0aUxi/J6mUlWbu/l+SHjWzFzSaJiSVrvigyZvUgykZKfpnTqmY2WckXSxps5k9JulD7n5zvlF17RWS/kjS/Y25akn6gLvfk2NM3Tpb0q2Nlf8BSf/o7qUuIayI50j6fOOtl3VJf+/u/5JvSIn8qaSFxnTGQ5KuzTmerjX+z/ZSSX/Sk+uXrRQSANAe0zIAUEEkdwCoIJI7AFQQyR0AKojkDgAVRHIHgAoiuQNABZHcAaCC/h9XoVDK3FAEIQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(X_train[y_train==0, 2], X_train[y_train==0, 3], color='r')\n",
    "plt.scatter(X_train[y_train==1, 2], X_train[y_train==1, 3], color='g')\n",
    "plt.scatter(X_train[y_train==2, 2], X_train[y_train==2, 3], color='b')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "from ML.knn import kNN_classify"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "predict_X = np.array([[5.1, 3.5, 1.4, 0.2], [5.9, 3. , 5.1, 1.8]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0.0, 2.0]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "kNN_classify(X_train, y_train, predict_X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "np.savetxt('x.txt', X_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "np.savetxt('y.txt', y_train)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
